/*
 * Copyright (c) chb my copyright message. 2022-2023. All rights reserved.
 *
 */

// 获取cookie
// export function getCookie(name) {
// return document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"))
// var arr = document.cookie.indexOf(name)
// console.log(name)
// console.log(arr)
// if (arr != null) {
//   return decodeURI(arr[2])
// } else {
//   return null
// }

// }

export function getCookie(key) {
  if (document.cookie.length > 0) {
    var arr = document.cookie.split(';');
    var value = '';  // 用于存储所需cookie值
    for (var i = 0; i < arr.length; i++) {
      var arr2 = arr[i].split('=');  // 再次切割
      if (arr2[0] == key) {
        value = arr2[1];
        console.log(value)
        return value;
      }
    }
  }
  return null
}
